<div class="charge_item banklist">
    <select data-am-selected class="am-form-field">
    </select>
</div>

<div class="common_container">
    <div class="charge_item name addr">
        <input type="text" class="am-form-field" placeholder="请填写开户网点" />
    </div>

    <div class="charge_item time account">
        <input type="number" class="am-form-field" placeholder="请填写银行卡卡号" style="font-weight: normal;" />
    </div>
</div>

<div class="name2">开户姓名：<span class="red">--</span></div>

<div style="margin: 15px;">
    <button type="button" class="am-btn am-btn-primary btn-save common_button">保存</button>
</div>

<style type="text/css">
    body {
        background-color: #ebeff0;
    }

    div.name2 {
        color: #4e4e50;
        margin: 5px 0px 15px 15px;
        font-size: 14px;
    }
</style>

<script>
    // 填充银行信息
    var s = $(".charge_item select");
    s.empty();
    for (var i in Util.banks) {
        s.append('<option value="__v__">__v__</option>'.replace(/__v__/g, Util.banks[i].name));
    }

    function drawCardInfo() {
        if (!context.user) return;

        // 开户姓名
        $("div.name span").html(context.user.user.name);

        var v = context.user.user.bank;
        if (!v || v == '') {
            return;
        }

        v = JSON.parse(v);

        $(".card .line1 .name").html(v.bank);
        $(".addr input").val(v.addr);
        $(".account input").val(v.account);

        $(".charge_item select").val(v.bank);
        $(".charge_item select").trigger('changed.selected.amui');
    }
    drawCardInfo();
    ME.cb = function() {
        ME.cb = null;
        drawCardInfo();
    };

    $(".btn-save").click(function() {
        var addr = $(".addr input").val().trim();
        var account = $(".account input").val().trim();
        if (addr == '') {
            alert2("请填写开户网点名称！");
            return;
        }
        if (account == '') {
            alert2("请填写您的银行卡卡号！");
            return;
        }

        startLoading();
        CMD.modify_user_info(undefined, {
            bank: JSON.stringify({
                bank: $(".charge_item select").val(),
                addr: addr,
                account: account,
            }),
        }, function() {
            stopLoading();
            alert2("保存完成！");
        });
    });
</script>
